# -*- coding: utf-8 -*-

# Define here the models for your scraped items
#
# See documentation in:
# https://doc.scrapy.org/en/latest/topics/items.html

import pymysql
import scrapy


class NovelItem(scrapy.Item):
    # define the fields for your item here like:
    id = scrapy.Field()
    name = scrapy.Field()
    type = scrapy.Field()
    author = scrapy.Field()
    #更新试卷
    update = scrapy.Field()
    #封面
    cover = scrapy.Field()
    #简洁
    introduction = scrapy.Field()
    #章节链接:
    chapter = scrapy.Field()
    #小说来源
    source = scrapy.Field()
    pass

class CharpterItem(scrapy.Item):
    # title = scrapy.Field()
    # no = scrapy.Field()
    id = scrapy.Field()
    # source = scrapy.Field()
    chapter= scrapy.Field()
    pass





if __name__ == '__main__':

    # 打开数据库连接
    db =pymysql.connect(
            host='127.0.0.1',  # 数据库地址
            port=3306,  # 数据库端口
            db='bookdb',  # 数据库名
            user='root',  # 数据库用户名
            passwd='wen123',  # 数据库密码
            charset='utf8',  # 编码方式
            use_unicode=True)

    # 使用cursor()方法获取操作游标
    cursor = db.cursor()

    # 使用 execute()  方法执行 SQL 查询
    cursor.execute(
                    """
                            SELECT * FROM `author` WHERE pen_name=%s
                    """,
                    ('a',
                     ))
    # print(int(db.insert_id()))

    # db.commit()
    # 使用 fetchone() 方法获取单条数据.
    data = cursor.fetchone()
    # data = cursor.fetchall()

    print(not data)
    # 关闭数据库连接
    db.close()